/******************************************************************************
 * (C) Copyright 2013 Atech-Automotive
 * FILE NAME:    uds_diag_config.h
 * DESCRIPTION:
 * 
 * DATE BEGUN:   2015/05/05
 * BY:           hui.pang
 * PRODUCT NAME:
 * APPLICATION:
 * TARGET H/W:
 * DOC REF:
 *****************************************************************************
 */

#ifndef _UDS_DIAG_CONFIG_H_
#define _UDS_DIAG_CONFIG_H_

/*****************************************************************************
**  typedef
*****************************************************************************/


/*****************************************************************************
**#include 
*****************************************************************************/
#include "system.h"

/*****************************************************************************
** Constant Macro Definition
*****************************************************************************/
#define _SEC_NONE_MODE          (0x00)    
#define _SUPP_ACCESS_01         (0x01)  /* don't change these values */
#define _SUPP_ACCESS_03         (0x02) 
#define _SUPP_ACCESS_05         (0x04) 
#define _SUPP_ACCESS_07         (0x08) 
#define _SUPP_ACCESS_09         (0x10) 

#define _NORMAL_MODE            (0x01) 
#define _DEFAULT_MODE           (0x02)
#define _PROGRAM_MODE           (0x04) 
#define _ENDOFLINE_MODE         (0x08) 


/* don't change these values */
#define SN                      0xFF
#define S0                      _SEC_NONE_MODE
#define S1                      _SUPP_ACCESS_01
#define S3                      _SUPP_ACCESS_03
#define S5                      _SUPP_ACCESS_05
#define S7                      _SUPP_ACCESS_07
#define S9                      _SUPP_ACCESS_09


#define CUSTOMER_EOL_MODE_1     SEC_01_MODE   /* SEC LEVEL 1 */
#define CUSTOMER_EOL_MODE_2     SEC_05_MODE   /* SEC LEVEL 2 */
#define ATECH_MODE              SEC_05_MODE

#define DEF_PHYS                BIT0
#define DEF_FUNC                BIT1
#define EXT_PHYS                BIT2
#define EXT_FUNC                BIT3
#define ALL_SUPPORT             (DEF_PHYS|DEF_FUNC|EXT_PHYS|EXT_FUNC)
#define FUNC_SUPPORT            (DEF_FUNC|EXT_FUNC) 
#define PHYS_SUPPORT            (DEF_PHYS|EXT_PHYS)
#define EXT_SUPPORT             (EXT_FUNC|EXT_PHYS)

#define LENGTH_NOT_SET          0xFFFF
#define LENGTH_MIN              0x8000

typedef struct{

    UINT8 u8_serid;
    UINT16 u16_serlength;
    UINT8 u8_supportSession;

}UdsServiceConfig_S; 


typedef struct{

    UINT8 u8_subid;
    UINT16 u16_sublength;
    UINT8 u8_enabledsession;

}UdsSubFunction_S;


/*****************************************************************************
** System Macro Definition
*****************************************************************************/


/*****************************************************************************
** Action Macro Definition
*****************************************************************************/


/*****************************************************************************
** Config Macro Definition
*****************************************************************************/


/*****************************************************************************
** Task Macro Definition
*****************************************************************************/


/*****************************************************************************
** Variables
*****************************************************************************/
/*
**  Global Var:  c_u32_can_tx_diag_id
**  Description: 
**               
**  Author:      2015/05/05, hui.pang create this Variable
*/
extern const UINT32 c_u32_can_tx_diag_id;

/*
**  Global Var:  c_u32_can_rx_diag_id
**  Description: 
**               
**  Author:      2015/05/05, hui.pang create this Variable
*/
extern const UINT32 c_u32_can_rx_diag_id;

/*
**  Global Var:  c_u32_can_rx_diag_id
**  Description: 
**               
**  Author:      2017/02/22, hui.liu create this Variable
*/
extern const UINT32 c_u32_can_rx_fun_diag_id;

extern const BOOL c_b_diag_stop_low_or_high_vbat;

extern const UINT8 c_u8_diag_low_vbat_th;
extern const UINT8 c_u8_diag_high_vbat_th;

extern const UINT16 c_u16_diag_low_vbat_off_time;
extern const UINT16 c_u16_diag_low_vbat_recover_time;
extern const UINT16 c_u16_diag_high_vbat_off_time;
extern const UINT16 c_u16_diag_high_vbat_recover_time;


extern const UINT16 c_u16_p2can_server_max;
extern const UINT16 c_u16_p2xcan_server_max;

/*    
** MODE_10_SUPPORTED
*/
extern const UdsServiceConfig_S c_s_udsServiceConfig[];
extern const UdsSubFunction_S c_s_uds0x10SubFunctionConfig[];
extern const UdsSubFunction_S c_s_uds0x11SubFunctionConfig[];
extern const UdsSubFunction_S c_s_uds0x19SubFunctionConfig[];
extern const UdsSubFunction_S c_s_uds0x27SubFunctionConfig[];
extern const UdsSubFunction_S c_s_uds0x28SubFunctionConfig[];
extern const UdsSubFunction_S c_s_uds0x31SubFunctionConfig[];
extern const UdsSubFunction_S c_s_uds0x3ESubFunctionConfig[];
extern const UdsSubFunction_S c_s_uds0x85SubFunctionConfig[];

extern const UINT8 c_b_0x10_support_default_to_pragram;

extern const UINT8 c_u8_0x11_ecu_reset_time;

extern const UINT8  c_b_0x14_diag_support_clear_single_dtc;

extern const UINT8 c_u8_0x19_dtc_supported_mask;

extern const UINT8 c_u8_0x27_access_diag_init_timer;

extern const UINT8 c_u8_access_invalid_attempt_counter;
extern const UINT16 c_u16_0x27_access_retry_time_interval;
extern const UINT16 c_u16_0x27_access_retry_time_interval_max;


extern const UINT8 c_u8_0x27_access_seed_lenght;

extern const BOOL c_b_0x23_sec_levels;
extern const BOOL c_b_0x3D_sec_levels;


extern const BOOL c_b_0x2F_cmd_return_to_ecu_cmd_enable;
extern const BOOL c_b_0x2F_cmd_reset_to_default_cmd_enable;
extern const BOOL c_b_0x2F_cmd_freeze_current_state_cmd_enable;
extern const BOOL c_b_0x2F_cmd_short_term_adjustment_enable;

/*****************************************************************************
** Constants
*****************************************************************************/


/*****************************************************************************
** Function prototypeseb
*****************************************************************************/


/*****************************************************************************
** other
*****************************************************************************/


/****************************************************************************/

#endif	//_UDS_DIAG_CONFIG_H_

/*****************************************************************************
** End File
*****************************************************************************/

